<?php
apf_require_class("APF_Interceptor");
apf_require_class("Bll_Hr_OutInterface");
apf_require_class("Util_Cookie");
apf_require_class("Util_Encrypt");
class BeComeUserInterceptor extends APF_Interceptor {
    public function before () {
        $this->_set_user_info();
        return self::STEP_CONTINUE;
    }

    public function after () {
        return self::STEP_CONTINUE;
    }

    private function _set_user_info(){
        $params = APF::get_instance()->get_request()->get_parameters();
        $ip = APF::get_instance()->get_request()->get_client_ip();
        if(substr($ip, 0,7) == '192.168' || $ip == '127.0.0.1'){
            if(isset($params['suid'])){
                $this->set_user_info($params['suid']);
            }
        }
        if($ip=='221.133.228.74' || $ip=='10.10.6.3'){
            if(isset($params['tzw_suid'])){
                $this->set_user_info($params['tzw_suid']);
            }
        }
    }
    private function set_user_info($uid){
        $user_info = Bll_Hr_OutInterface::get_instance()->get_user_base_info($uid,1);
        Util_Cookie::set_cookie($user_info);
    }
}